//
//  CellOfSearchForThread.m
//  PetAPP
//
//  Created by apple on 16/2/25.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "CellOfSearchForThread.h"
#import "ModelOfSearchThread.h"
#import <YYWebImage.h>

@interface CellOfSearchForThread ()

@property (nonatomic, retain) UIImageView *imageViewOfPic;

@property (nonatomic, retain) UILabel *labelOfTime;

@property (nonatomic, retain) UILabel *labelOfSee;

@property (nonatomic, retain) UILabel *labelOfReplies;

@property (nonatomic, retain) UIImageView *imageViewOfTime;

@property (nonatomic, retain) UIImageView *imageViewOfSee;

@property (nonatomic, retain) UIImageView *imageViewOfReplies;

@end

@implementation CellOfSearchForThread

- (void)dealloc {

    [_imageViewOfPic release];
    [_labelOfTitle release];
    [_labelOfTime release];
    [_labelOfSee release];
    [_labelOfReplies release];
    [_imageViewOfTime release];
    [_imageViewOfSee release];
    [_imageViewOfReplies release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.imageViewOfPic = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfPic];
    [_imageViewOfPic release];
    
    self.labelOfTitle = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfTitle];
    [_labelOfTitle release];
    
    
    self.labelOfTime = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfTime];
    [_labelOfTime release];
    self.labelOfTime.textColor = [UIColor grayColor];
    self.labelOfTime.font = [UIFont systemFontOfSize:15];
    
    self.labelOfSee = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfSee];
    [_labelOfSee release];
    self.labelOfSee.textColor = [UIColor grayColor];
    self.labelOfSee.font = [UIFont systemFontOfSize:15];
    
    self.labelOfReplies = [[UILabel alloc] init];
    [self.contentView addSubview:_labelOfReplies];
    [_labelOfReplies release];
    self.labelOfReplies.textColor = [UIColor grayColor];
    self.labelOfReplies.font = [UIFont systemFontOfSize:15];
    
    self.imageViewOfTime = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfTime];
    [_imageViewOfTime release];
    
    self.imageViewOfSee = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfSee];
    [_imageViewOfSee release];
    
    self.imageViewOfReplies = [[UIImageView alloc] init];
    [self.contentView addSubview:_imageViewOfReplies];
    [_imageViewOfReplies release];
    
    
    
}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.imageViewOfPic.frame = CGRectMake(10, 10, 50, 50);
    self.imageViewOfPic.layer.cornerRadius = 25;
    self.imageViewOfPic.layer.masksToBounds = YES;
    
    self.labelOfTitle.frame = CGRectMake(70, 10, self.contentView.frame.size.width - 80, 20);
    
    self.imageViewOfTime.frame = CGRectMake(70, 40, 20, 20);
    
    self.labelOfTime.frame = CGRectMake(95, 40, 70, 20);
    
    self.imageViewOfSee.frame = CGRectMake(170, 40, 20, 20);
    
    self.labelOfSee.frame = CGRectMake(195, 40, 50, 20);
    
    self.imageViewOfReplies.frame = CGRectMake(270, 40, 20, 20);
    
    self.labelOfReplies.frame = CGRectMake(295, 40, 50, 20);

}

- (void)handleDataWithModel:(ModelOfSearchThread *)model {

//    self.imageViewOfPic.yy_imageURL = [NSURL URLWithString:model.userface];
    [self.imageViewOfPic yy_setImageWithURL:[NSURL URLWithString:model.userface] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];

    
    self.labelOfTitle.text = model.message;
    
    NSRange range = NSMakeRange(5, 5);
    
    self.labelOfTime.text = [model.dateline substringWithRange:range];
    
    self.labelOfSee.text = model.views;
    
    self.labelOfReplies.text = model.replies;
    
    self.imageViewOfTime.image = [UIImage imageNamed:@"shijian"];
    
    self.imageViewOfSee.image = [UIImage imageNamed:@"guankan"];
    
    self.imageViewOfReplies.image = [UIImage imageNamed:@"huifu2"];


}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
